#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

from PyQt4.QtCore       import *
from PyQt4.QtGui        import *

from mainwindow         import MainWindow

def main(argv):
    """
    
    Arguments:
    - `argv`:
    """

    codec = QTextCodec.codecForName("utf8")
    QTextCodec.setCodecForLocale(codec)
    QTextCodec.setCodecForCStrings(codec)

    app = QApplication(argv)

    win = MainWindow()
    win.set_title("image viewer")

    fn = argv[-1]

    if win._is_image_fn(fn):
        win.set_image(fn)
    else:
        win.set_image(".")
    win.show()

    sys.exit(app.exec_())

if __name__ == '__main__':
    main(sys.argv)

